//
//  NewsCustomCollectionViewCell.m
//  SYiDaiy
//
//  Created by dllo on 16/9/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "NewsCustomCollectionViewCell.h"
#import "TAMacro.h"
@implementation NewsCustomCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _flow = [UICollectionViewFlowLayout new];
        CGFloat width = (SCREEN_WIDTH - 40) / 3;
        _flow.itemSize = CGSizeMake(width, 180);
        _flow.minimumLineSpacing = 10;
        _flow.minimumInteritemSpacing = 10;
        _flow.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
        _flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        _newsTopCollection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200) collectionViewLayout:_flow];
        _newsTopCollection.backgroundColor = [UIColor orangeColor];
        _newsTopCollection.dataSource = self;
        [self addSubview:_newsTopCollection];
        
        [_newsTopCollection registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"newsTopCollectionCell"];
        
        _sourceLabel= [UILabel new];
        _sourceLabel.font = [UIFont systemFontOfSize:17];
        _sourceLabel.alpha = 0.4;
        [self.contentView addSubview:_sourceLabel];
        _titleLabel = [UILabel new];
        _titleLabel.font = [UIFont systemFontOfSize:16];
        _titleLabel.numberOfLines = 0;
        [self.contentView addSubview:_titleLabel];
        _authorLabel = [UILabel new];
        _authorLabel.font = [UIFont systemFontOfSize:15];
        _authorLabel.alpha = 0.4;
        [self.contentView addSubview:_authorLabel];
        _pubdateLabel = [UILabel new];
        _pubdateLabel.font = [UIFont systemFontOfSize:15];
        _pubdateLabel.alpha = 0.4;
        [self.contentView addSubview:_pubdateLabel];
        _fineLine = [[UIView alloc] init];
        _fineLine.backgroundColor = [UIColor blackColor];
        _fineLine.alpha = 0.3;
        [self.contentView addSubview:_fineLine];
        _contentLabel = [UILabel new];
        _contentLabel.font = [UIFont systemFontOfSize:14];
        _contentLabel.numberOfLines = 0;
        [self.contentView addSubview:_contentLabel];
    }
    return self;
}

- (void)layoutSubviews
{
    
    
    
    _sourceLabel.frame = CGRectMake(10, 210, SCREEN_WIDTH - 10, 20);
    _titleLabel.frame = CGRectMake(10, 230, SCREEN_WIDTH - 60, 60);
    _authorLabel.frame = CGRectMake(10, 290, 180, 20);
    _pubdateLabel.frame = CGRectMake(220, 290, SCREEN_WIDTH - 20, 20);
    _fineLine.frame = CGRectMake(10, 320, SCREEN_WIDTH - 20, 1);
    _contentLabel.frame = CGRectMake(10, 330, SCREEN_WIDTH - 20, 300);
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"newsTopCollectionCell" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor redColor];
    UIImageView *topImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, (SCREEN_WIDTH - 40) / 3, 180)];
    topImageView.image = [UIImage imageNamed:@"0"];
    [cell.contentView addSubview:topImageView];
    
    return cell;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 4;
}


- (void)awakeFromNib {
    // Initialization code
}

@end
